/*
+--------------------------
| FreeloaderOS v0.0.1
|  - Microkernel
+--------------------------
| Written by Alec Hussey
| Copyright (c) 2007
|  - Deus X Foundation
+---------------------------
*/

/*
 * Standard C Library
 */

#include <system.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>

/*
Raise a number to the input power.
*/
long int pow(unsigned int number, unsigned int power)
{
	unsigned int i;
	long int retval = 1;
	
	for (i=1; i <= power; i++)
		retval = retval * number;
	
	return retval;
}

/*
Convert a decimal to a hexadecimal.
*/
void decimaltohex(unsigned int decval)
{
	int i;
	int c;
	int a[20];
	unsigned long b = decval;
	
	while (b > 15)
	{
		a[i] = b % 16;
		b /= 16;
		i++;
		c++;
	}
	
	a[i] = b;
	
	for (i = c; i >= 0; i--)
	{
		switch (a[i])
		{
		case 10:
			putch('A');
			break;
		case 11:
			putch('B');
			break;
		case 12:
			putch('C');
			break;
		case 13:
			putch('D');
			break;
		case 14:
			putch('E');
			break;
		case 15:
			putch('F');
			break;
		default:
			putch(a[i]+48);
			break;
		}
	}
}
